const path = require("path");
const { name } = require("./package");

const port = "8082";
const isDev = process.env.NODE_ENV === "development";

const resolve = (dir) => {
  return path.join(__dirname, dir);
};
module.exports = {
  // publicPath: isDev ? "/" : "/child/tradePurchase/", // 如果是独立部署，publicPath默认'/'即可。
  transpileDependencies: true,
  devServer: {
    hot: true,
    host: "0.0.0.0",
    port,
    headers: {
      "Access-Control-Allow-Origin": "*",
    },
    proxy: {},
  },
  chainWebpack: (config) => {
    config.optimization
      .minimize(true)
      .minimizer("terser")
      .tap((args) => {
        let { terserOptions } = args[0];
        terserOptions.compress.drop_console = true;
        terserOptions.compress.drop_debugger = true;
        return args;
      });
  },
  configureWebpack: {
    resolve: {
      alias: {
        "@": resolve("src"),
      },
    },
    output: {
      library: `${name}-[name]`,
      libraryTarget: "umd",
      chunkLoadingGlobal: `webpackJsonp_${name}`,
    },
  },
};
